package pt.spjm.pmartins.lapcounter;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class Setup_Events_Add extends Activity {

	private Obj_CurrentData cData;
	private EditText timeLimit;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.setup_events_add);

		timeLimit = (EditText) findViewById(R.id.newEventTimeLimit);
		cData = LapCounter.cData;
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.setup__events__add, menu);
		return true;
	}

	public void onNewEventSaveBtn(View v){
		try{
			int time = Integer.parseInt(timeLimit.getText().toString());
	
			if (time < 1 || time > 60) {
				throw new IllegalArgumentException();
			}
			
			cData.getEventsData().setTimeLimit(timeLimit.getText().toString() + ":");
			
		} catch(Exception e){
			//Not valid
		}
	}
}
